package com.example.mybatis.controller;

import com.example.mybatis.service.FileService;
import com.example.mybatis.utils.ResultUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("file")
public class FileController {
    @Resource
   FileService fileService;

    @RequestMapping("upload")
    public ResultUtil upload(MultipartFile file, HttpServletRequest request){
        return fileService.upload(file,request);
    }

    @RequestMapping("delete")
    public ResultUtil delete(String  fileName){
        return fileService.delete(fileName);
    }

    @RequestMapping("readExcel")
    public ResultUtil readExcel(MultipartFile file,Integer detailsId) {
        return fileService.readExcel(file,detailsId);
    }


    @RequestMapping("exportExcel")
    public ResultUtil exportExcel(HttpServletResponse response){
        return fileService.exportExcel(response);
    }

}
